Empowering coffee farming using counterfactual recommendation based RNN driven IoT integrated soil quality command system

Soil health is essential for whirling stale soil into rich coffee-growing land. By keeping healthy soil, coffee producers may improve plant growth, leaf health, buds, cherry and bean quality, and yield. Traditional soil monitoring is tedious, time-consuming, and error-prone. Enhancing the monitoring system using AI-based IoT technologies for quick and precise changes. Integrated soil fertility control system to optimize soil health, maximize efficiency, promote sustainability, and prevent crop threads using real-time data analysis to turn infertile land into fertile land. The RNN-IoT approach uses IoT sensors in the coffee plantation to collect real-time data on soil temperature, moisture, pH, nutrient levels, weather, CO2 levels, EC, TDS, and historical data. Data transmission using a wireless cloud platform. Testing and training using recurrent neural networks (RNNs) and gated recurrent units gathered data for predicting soil conditions and crop hazards. Researchers are carrying out detailed qualitative testing to evaluate the proposed RNN-IoT approach. Utilize counterfactual recommendations for developing alternative strategies for irrigation, fertilization, fertilizer regulation, and crop management, taking into account the existing soil conditions, forecasts, and historical data. The accuracy is evaluated by comparing it to other deep learning algorithms. The utilization of the RNN-IoT methodology for soil health monitoring enhances both efficiency and accuracy in comparison to conventional soil monitoring methods. Minimized the ecological impact by minimizing water and fertilizer utilization. Enhanced farmer decision-making and data accessibility with a mobile application that provides real-time data, AI-generated suggestions, and the ability to detect possible crop hazards for swift action.

In the nineteenth century, coffee cultivation in Brazil began to expand into the Cerrado region.The Cerrado is a vast region of savanna with poor soils.However, Brazilian coffee farmers developed new techniques for improving the soil, such as using lime and fertilizer.As a result, the Cerrado is now the world's largest coffeeproducing region.The components nitrogen, phosphorus, potassium, calcium, magnesium, Sulphur, and iron can all be found in soil that is considered fertile 1 .The optimal soil for growing coffee is loamy soil, found in the state of north Karnataka, India which has a good combination of texture, drainage, and water retention.Coffee plantation soil requires well-drained soil to prevent waterlogging and root rot.Coffee plants have extensive root systems that extend deep into the soil to absorb nutrients and water 2 .The presence of nutrient-rich soil serves as the fundamental basis for the optimal growth and development of coffee plants, hence facilitating the production of superior-grade coffee beans.Fertility refers to the soil's ability to provide essential nutrients for plant growth, such as nitrogen, phosphorus, and potassium.Healthy soil leads to healthier coffee plants, which produce higher yields of high-quality beans.Coffee plants thrive in slightly acidic soil with a pH of 5.0-6.5.

Literature review
Aarthi, R., Sivakumar, D., et al., proposed the optimal watering schedule and fertilizer application rate.IoT software platforms that can be used to develop smart soil property analysis systems such as Thing Speak, Blynk, Cayenne, Node-RED, and Azure IoT Hub.Smart soil property analysis systems can provide real-time soil conditions data, allowing farmers to respond quickly to any changes.Future work is to develop more sophisticated machine learning models to improve the accuracy of the predictions 6 .Na, A., Isaac, W., Varshney, S, et al., proposed an Internet of Things (IoT)-based system for remote monitoring of soil characteristics a system that employs sensors to collect data on soil properties, such as pH, electrical conductivity (EC), moisture, temperature, and then communicates this data to a cloud platform or another remote location.These soil qualities include electrical conductivity (EC), pH, and temperature 7 .Jain, N., Awasthi, Y et al., proposed an IoT-based soil analysis system using optical sensors and multivariate regression is a system that uses optical sensors to measure the color and reflectance of soil and then uses multivariate regression to predict soil properties, such as pH, organic matter, and nutrient content.IoT-based soil analysis systems can be made small and portable, making them ideal for field use.Future work on IoT-based soil analysis systems could focus on making IoT-based soil analysis systems more affordable and accessible to small-scale farmers 8 .Patil, P et al., proposed the implementation of IoT to determine the level of bicarbonate in the soil a system that uses sensors to measure the pH and electrical conductivity (EC) of soil and then uses this data to calculate the bicarbonate level.IoT-based bicarbonate detection systems can provide users with the data they need to make informed decisions about irrigation, fertilization, and other agricultural practices 9 .Adrian Z et al. proposed integrating soil pH measurement into an Internet of Things (IoT) application a concept that involves using sensors to measure soil pH and then transmitting this data to a cloud platform or other remote location using a wireless communication protocol.The dataset collected by IoT-based soil pH measurement systems typically includes soil pH, Temperature, Humidity, Electrical conductivity (EC), and Timestamp 10 as illustrated in Table 1.
IoT (Internet of Things) is a key enabling technology for smart agriculture, as it allows for the collection and analysis of data from sensors in real-time.IoT-based soil parameter measurement systems can provide real-time data on soil parameters, which allows farmers to respond quickly to changes.Future work on IoT-based soil parameter measurement systems could focus on making the systems easier to set up and maintain 18 .The materials and methods section describes how the soil is fertilized using IoT sensors and Cloud storage.

The proposed model
The primary objective of this research study was to monitor the overall condition of the soil and to design an advanced algorithm called RNN-IoT.The present techniques for measuring soil health based on existing and past guidelines have yielded inaccurate results.The suggested approach has successfully addressed all of the aforementioned limitations and obtained a predictable outcome in transforming barren land into sustainable and rich soil suitable for coffee cultivation.Sensors measure soil potassium, phosphorus, and nitrogen levels and concentrations together with NPK color value indicators 19 .As demonstrated in Fig. 1, the N95S31B NB-IoT outdoor temperature and humidity sensor accurately measures air temperature and relative humidity.

Build an IoT sensor network to monitor soil health
It subsequently sends data to an IoT server over NB-IoT.CO2 sensors measure CO.The waterproof, sturdy CO2 concentration transmitter outputs 0-10 V. Nordic nRF9160 SiP is a low-power, single-chip cellular IoT solution.Its Arm Cortex-M33 CPU, low-power RF transceiver, and multiple ports make it adaptable.The Nordic nRF9160 SiP's ADC peripheral measures soil moisture.SiP receives soil moisture sensor data 20 .The Soil EC

Protocol for interfacing serial technology (IST)
Soil moisture sensors measure volumetric water content.Two electrodes detect soil electrical resistance, which fluctuates with water content.Sensor output is usually a soil moisture-proportional voltage or frequency as indicated in Eq. ( 1).Where VWC is the volumetric water content which finds the percentage of soil volume occupied by water, can be calculated based on the weight of the wet soil minus the weight of the dry soil which divides the weight of the dry soil.εa is the apparent dielectric permittivity of the soil, εb is the dielectric permittivity of dry soil, εc is the dielectric permittivity of water.Where ρn is the neutron count rate in the soil, ρd is the neutron count rate in dry soil, and ρw is the neutron count rate in water as indicated in Eq. ( 2).
where R is soil electrical resistance and M and N are calibration constants from Eq. (3).A soil temperature sensor is needed to understand soil activity and plant growth 22 .It employs thermistors or thermocouples, whose resistance changes with temperature.Equation ( 4) shows that the sensor's voltage or current output is proportional to soil temperature.Where T is soil temperature, R is thermistor electrical resistance, and A and B are calibration coefficients.
Water level indicators assess soil water table depth.It employs a pressure transducer or ultrasonic sensor to detect water-induced pressure or sound reflection.Sensor output is generally a water level-proportional voltage or frequency.An NPK color value indicator evaluates soil nitrogen, phosphorus, and potassium levels.It measures soil extract color with a colorimetric sensor.Sensor output is generally an RGB color value or a numerical NPK level value.A GPS sensor locates the soil monitoring spot.GPS satellites inform it of its latitude, longitude, and altitude.The sensor sends NMEA messages with location coordinates as indicated in Eqs. ( 5), (6), and ( 7).
(1) where ϕ is the geodetic latitude, is the longitude, δ is the sun's declination, R is the Earth's mean radius (6371 km), R 0 is its equatorial radius (6378 km), h is the GPS antenna's height above the Earth's surface, and ϕ 0 is the reference ellipsoid's latitude (43.66°LDRs (light-dependent resistors) measure soil color to determine nutrient content.It usually uses an LDR, which changes resistance when exposed to different wavelengths of light.
Sensor output is generally a resistance value that fluctuates proportionately with soil color as indicated in Eq. ( 8).
where R is the reflected light, Cr is the red light component of the incident light, Cg is the green light component of the incident light, Cb is the blue light component of the incident light, and Cw is the white light component of the incident light.Soils with higher organic matter content tend to reflect more red light and less blue light, while soils with lower organic matter content tend to reflect more blue light and less red light.A pH sensor monitors the acidity or alkalinity of the soil.Typically, it employs a glass electrode that generates a voltage that varies by the pH of the solution that it is surrounded by.The output of the sensor is often in the form of a voltage, and its magnitude is typically proportional to the pH of the soil as shown in Eq. ( 9).
pH is soil acidity or alkalinity and pH+ is hydrogen ion activity in the soil solution.Each soil health measurement is timestamped.Even when the gadget is off, its real-time clock (RTC) preserves precise time.Synchronizing soil health data with other sources and tracking changes requires the timestamp.(5) Latitude = ArcTan2(sin(ϕ), cos(ϕ) * cos( ))

Configuration of sensor data transmission for arduino microcontroller
For analysts to collect precise measurements of crucial soil characteristics like temperature, moisture, PH, CO2, fertilizer level, and nutrient concentrations, sensors are submerged far below the surface of the soil 23 .The Arduino microcontroller serves as the system's primary central processing unit (CPU).It is in charge of gathering information from the sensors, processing that information, and then sending it to a computer or Laptop, Mobile Phone for utilization as indicated in Fig. 3. Arduino Uno, Wi-Fi module ESP8266, Jumper wires, breadboard, and 5 V Power Supply.

From an Arduino microcontroller to a Node MCU to the cloud
Arduino microcontrollers capture soil health data from connected sensors as the main data acquisition unit communicating with linked sensors, reading output values, and processing sensor data as requested.Arduino microcontrollers gather soil health data from sensors as the main data-collecting unit communicating with linked sensors, reading output values, and processing sensor data 24 .The Node MCU stores data in the cloud and uses AWS IoT Core for visualization, and these services are accessed through the Node MCU as indicated in Fig. 4.
Cloud Interface provides dashboards or visualization tools to monitor the uploaded sensor data in real time or over time.The data can be analyzed to identify patterns, trends, and anomalies, providing valuable insights

Recurrent neural network
The raw data was delivered to the input layer, where it was often preprocessed and normalized to ensure network interoperability.Load the CSV file into Panda's data frame.Preprocess the data by performing necessary steps such as cleaning, handling missing values, and feature selection.Sequence formation has sequence length is a variable that determines the length of each sequence to be created.An empty list called sequences is initialized to store the generated sequences.Formula for GRU-based Soil Health Monitoring where, h_t is the hidden state of the GRU at time step t, h_{t − 1} is the hidden state of the GRU at time step t − 1, h_t̃ is the candidate hidden state at time step t, gate_update is the update gate, gate_reset is the reset gate.
The update gate controls which information is allowed to flow into the hidden state from the previous time step where W_h is the weight matrix for the hidden-to-hidden state connection, U_x is the weight matrix for the input-to-hidden state connection, b_h is the bias vector for the hidden state, x_t is the input at time step t.
Loops from 0 to len(data)-sequence length + 1.This loop generates dataset sequences.Unfold the RNN into interconnected layers with input, forget, cell, and output gates.Input the current input into the input gate to regulate information flow into the hidden state.Apply the forget gate on the previous hidden state to determine how much to remember.Update the cell state depending on the input gate, forget gate and previous hidden state cell state that stores sequence long-term memory.
Consider C t as the cell state at time step t, C {t−1} at time step t − 1, and h {t−1} as the forget gate i t is the input gate, tanh is the hyperbolic tangent activation function, W h and U x are the hidden-to-hidden and input-to-hidden weight matrices, respectively.At time step t, b c is the bias vector for the cell state, x t is the input, and h {t−1} is the hidden state.Use the output gate to create the current time step output that passes cell state information.Gated recurrent units (GRUs) architecture trains the dataset properly depending on soil prediction features.At each time step, calculate the error between expected and actual output.Back propagates the error via the unrolled RNN to calculate weight error gradients.Update weights to reduce inaccuracy.Prediction and Analysis in the RNN model increase warnings and suggestions by predicting soil health metrics from real-time sensor inputs.Historical sensor data, growth trends, and FFNN soil health results train the model 25 .Change specifics to simulate scenarios.

Counter-factual recommendation generation
Parameters within historical data to represent various 'what-if ' situations.It compares with the actual generated out with historical data to generate recommendations.They are comparing the recommendation using three ways Present data-Historical data, Historical data-Historical data, and Present data-Present data as illustrated in Fig. 5.
For example, let us contemplate a hypothetical situation in which a soil health monitoring system, based on feedforward neural network (FFNN) architecture, provides a recommendation for the optimal application rate of fertilizer for a particular agricultural area.Counterfactual suggestion has the potential to be employed to generate alternative fertilizer recommendations.Manhattan distance, often known as taxi cab distance, is calculated by adding the absolute coordinate differences of two places.Imagine traveling solely horizontally or vertically in Manhattan's grid.Distance is calculated using present and historical data.Consider N points in K-dimensional space, where 2 < = N < = 10^ {5} and 1 < = K < = 5.Find the location with the lowest Manhattan distance from (10)   The Manhattan Distance, which indicates the dissimilarity between the current suggestion and several alternative fertilizer options, may be calculated as shown in Eq. ( 13), where |s 1 − s 2 | denotes the absolute difference between the two points' s-coordinates.|r 1 − r 2 | is the absolute difference in r-coordinates.The calculation considers nutritional content, application rates, and environmental effects.The system may create counterfactual suggestions with Manhattan Distances below a threshold.This keeps alternate options comparable to the original advice while allowing for varied perspectives.The implementation phase collects and analyzes data.

Results and discussion
The field implementation of the AI-powered system involved deploying IoT sensors in selected infertile agricultural fields to collect real-time soil data.These sensors continuously monitor soil properties such as moisture, temperature, pH, nutrient levels, and electrical conductivity.XG-booster is used for the pre-training model for predicting specific soil properties (e.g., nutrient content, and moisture levels) based on sensor data.The collected data was then fed into the AI system, which employed RNNs and GRUs to identify patterns and trends in soil health indicators as indicated in Fig. 6.

Field setup for improving soil fertility
Enhancing the fertility of the soil is essential for achieving sustainable agriculture and achieving maximum crop yields.To evaluate and enhance the fertility of the soil throughout a range of monitoring periods, this experiment describes a field design that makes use of several land portions.Datasets are collected in real-time from Madikeri, Coorg, Karnataka total of 640, monthly monitoring based on historical data from the past three years recorded around 300582.

Performance evaluation compared with RNN
A proposed model is compared to existing models to determine its accuracy.Table 3 shows random forest, SVM, K-means clustering, GAN, and feed-forward neural network.This performance is measured using several metrics, including accuracy, precision, recall, and F 1 score.Accuracy is the most straightforward metric, measuring the proportion of correct predictions made by the model.Precision measures the proportion of correct positive predictions.Recall, also known as sensitivity, measures the proportion of actual positive instances that are correctly identified as positive.
The proposed method achieves 94.25% accuracy, while random forest, SVM, K-means clustering, GAN, and FFNN obtain 81.22%, 81.66%, 82.12%, 88.12%, and 89.73%.Existing approaches take longer to calculate all datasets.Figure 7 shows that the suggested technique detects events better than current methods.High EC and TDS readings indicate excessive salinity, which can stress and reduce coffee plant output.Most of the 30-day monitoring period had optimum EC and TDS values.NPK levels reflect coffee plant nutrient availability.Low nitrogen, phosphorus, and potassium (NPK) levels can decrease coffee plant output.The reduction in NPK levels from day 11-30 suggests dietary replenishment.During days 1-10, the soil moisture was a little dry, but otherwise, it was excellent.The rain prevented soil desiccation and reduced coffee plant stress.Figure 8 shows that soil temperature also affects coffee plant development.Coffee plants like soil temperatures between 20 and

Optimization of the model
To keep the coffee plants healthy and the farm skiing, it is important to monitor the soil health of the plantations.Beans with more robust scents and tastes are a product of soil that is both healthy and well-tended.Farmers may maximize water and fertilizer efficiency and cut down on production expenses by learning what their soil requires to be healthy.To maintain healthy and fertile soil over the long term, it is important to evaluate it regularly for signs of nutrient imbalances.Weekly data analysis utilizing the RNN model is used to monitor soil conditions, and farmers are updated on health-related information and comments about soil quality.For a more precise prediction, we compare the soil condition from the second week of monitoring with that from the first week.
In a similar way comparing week 2 with week 1 generates correct results, comparing week 3 with week 2 and so on also yields accurate results.

Measurements taken to enrich the soil of coffee plantations in arid regions
When substantially monitoring and tracking various essential indicators such as electrical conductivity (EC), total dissolved solids (TDS), nitrogen (N), phosphorus (P), potassium (K), soil moisture, soil temperature, carbon dioxide (CO2), and soil pH, agricultural practitioners can promptly detect potential issues and implement appropriate measures to uphold an optimal ecosystem for their coffee crops.The soil solution's EC and TDS levels indicate salt content as indicated in Table 4. CO2 levels rose somewhat from day 11-20, indicating a healthier soil microbial community.Coffee plants thrive best at 5.5-6.5 soil pH as illustrated in Fig. 9.The soil pH remained within the correct range during the monitoring period, ensuring that coffee plants could easily obtain nutrients as shown in Table 5. Rainfall is vital     to soil hydration.The monitoring period was without significant precipitation from day one to day fourteen.This shows that irrigation was needed to maintain soil moisture levels throughout this era.Day 15 brought 15 mm of rain, restoring soil moisture.Coffee plant soil health measurements were within optimal levels for most of the 140-day monitoring period from week 1 to week 20.

Counter-factual recommendation
RNN-IoT model uses historical data and real-time sensor readings to predict future soil states and potential crop threats.Based on these predictions, the system generates counterfactual recommendations-alternative actions your farm could take to achieve desired outcomes.

Mobile application sample
The mobile application was created with the open-source Google framework Flutter, employing JavaScript.The RCNN model has been integrated and implemented, resulting in the generation of recommendations.These recommendations are created using Counterfactual suggestions.Figure 10 is a discussion based on the question raised by the agriculturist from various parts of the coffee plantation growers.Soil-rich mobile-based applications will provide recommendations after analyzing sensor data.Agriculturist question was "How do soil conditions that are too dry, too wet, too cold, or too hot affect coffee plants".The recommendation is generated as High or low soil pH can make it difficult for coffee plants to absorb nutrients.Solution: Apply soil amendments to adjust the pH to the optimal range.The specific type of soil amendment to apply will depend on the current soil pH and the desired pH range.Similarly, "How does rainfall affect coffee plants, and what can coffee growers do to mitigate the negative effects of extreme rainfall events".The recommendation is generated as Insufficient or excessive rainfall can lead to water stress or soil erosion.Irrigate during periods of low rainfall and implement erosion control measures during periods of high rainfall.Monitoring rainfall patterns is important to ensure that coffee plants receive the right amount of water 26 .The proposed model is trained using the Training Set, which enables it to discover hyperlinks and patterns in the data.To minimize loss and enhance predictions.To evaluate the model's performance and adjust its hyperparameters, a validation set is utilized during its development.Evaluates the model's ability to be extrapolated to new data, which helps avoid excess fitting.The testing set is utilized for the final and unbiased evaluation of the model's performance once all training and hyper-parameter adjustments have been finished.Ensures the model's ability to apply knowledge to unfamiliar data and offers an accurate evaluation of its capabilities as shown in Fig. 11.The total dataset is divided into 60% for training, 20% for validation, and 20% for testing.The difference between predicted and actual values is computed using a loss function by mean square error.The loss is propagated backward through time, updating model parameters (weights and biases) to minimize the loss.
A confusion matrix is an illustrative format that exhibits the success of a proposed theory 27 .The data represents the observed vs projected results for each week of monitoring.Within the realm of soil fertility, weekdays may be classified as several tiers of fertility.For instance, weeks 1-7 exhibit low fertility, weeks 8-14 demonstrate medium fertility, and weeks 15-20 showcase high fertility, making them suitable for cultivation as shown in Fig. 12.
By using IoT sensors to track soil moisture, temperature, pH, and nutrient levels, coffee farmers can gain valuable insights into their crops' health and needs.Figure 13 data can then be used to make informed decisions about irrigation, fertilization, and other agricultural practices-a 20-week soil monitoring study that tracks the soil condition in a coffee plantation.The study was conducted in a coffee plantation in Madekari, Coorg, and Karnataka, India.Ten IoT sensors were installed on the plantation, and data was collected every hour for 20 weeks.The sensors measured soil moisture, temperature, and pH at a depth of 10 cm throughout 20 weeks.Due to heavy rainfall in the early weeks of the research, soil moisture was maximum.Dry weather diminished soil moisture.The study's soil temperature peaked in the first weeks and then dropped as the weather cooled.pH was almost consistent throughout the investigation.20-week.The investigation produced soil moisture, temperature, and pH maps.These maps helped identify under and over-watered crop regions and regulate the irrigation system.The maps were also utilized to identify acidic and alkaline soil on the farm and adapt the fertilization program.

Conclusion
The foreseeable future of coffee production demands beyond merely cultivating a diverse range of coffee beans; it involves establishing a sustainable and lucrative coffee business that will endure for future generations.Utilizing sophisticated sensors allows for the monitoring of environmental variables, including precipitation, humidity, and temperature, to optimize agricultural productivity.Internet of Things (IoT) devices have the potential to accurately assess the levels of water and nitrogen present in soil.Furthermore, by assessing the CO2 concentration in agricultural areas, it is possible to accurately monitor evapotranspiration rates, therefore enhancing the monitoring of soil health.This requires equipping coffee growers with the necessary tools and expertise to develop intelligent soil-a flexible and robust ecosystem that supports the growth of healthy coffee plants while reducing environmental harm.Farmers are provided with immediate updates on the condition of their soil and  receive alerts on any potential issues.This enables farmers to promptly address any early signs of soil degradation.The Recurrent Neural Network and Counterfactual Recommendations utilize advanced algorithms to forecast future trends and provide tailored soil cures for youthful agriculturists.Knowledgeable farmers make well-informed choices regarding their soil, leading to higher crop production, better quality, and more profitability.The proposed method has overcome all of the above drawbacks and achieved the predictable result for converting infertile land to fertile land sustainable for coffee plantations.
The future direction is moving towards installed outside Internet of Things devices are subject to severe weather, dust, wind, temperature, and other environmental hazards.This is one of the main issues with these devices.Unexpected mechanical failure of the complex devices could occur as a result of unfavorable environmental circumstances.Therefore, the raw materials used to construct the Internet of Things (IoT) devices used in smart farming must be able to endure such harsh climatic conditions.This will ensure that the devices last longer and provide more consistent results.Coffee cherry early detection and recommendation based on advanced deep learning technology which empowers farmers to cultivate a sustainable future for coffee, one smart earth revolution at a time.

Challenges and future possibilities
Global research on the Internet of Things (IoT) and sensor-based smart farming have revealed positive results.It is employed in several small-scale agricultural domains a rural farm, where farmers have less technological expertise, may provide more challenges.Even so, the execution of the project on a broad scale is still awaiting completion.An obstacle of great importance is the financial burden associated with the deployment and installation of IoT-tagged sensors and accessories in vast agricultural areas.Furthermore, there is ambiguity regarding the expenses associated with implementation and the monetary benefits that may be obtained.Deploying IoTenabled technology incurs substantial expenses for hardware, software, and system operation.Supplementary costs may encompass energy usage, system upkeep, service enrollment, and labor fees for operating combined hardware and software.Enhancing farmers' digital literacy on a global scale is crucial to facilitating the extensive use of IoT technologies.Lack of comprehension and consciousness of IoT-based technologies in agriculture might result in the underutilization of intelligent systems in farming 28 .Government policymakers should develop economic strategies to facilitate the successful and efficient implementation of Internet of Things (IoT) technology by farmers in agricultural areas.Data privacy and security issues might hinder large-scale IoT and smart system adoption.Attackers can manipulate cloud server data to harm automated agricultural activities in farmlands.Attacks can negatively impact agricultural output and prevent good environmental management.IoT data security concerns contribute to the sluggish adoption of smart farming systems.Encryption is crucial for protecting critical data and digital systems in smart farming from global cyberattacks.Integrating cryptography with strong keys can reduce cyber threats on cloud systems.Additional methods, such as integrating multiparty computing with homomorphic encryption or block-chain, can yield accurate results.

Figure 2 .
Figure 2. Virtual abstract for proposed system.

Figure 4 .
Figure 4.The connection between Arduino board to cloud storage.

Figure 7 .
Figure 7. Result analysis for the proposed approach.

Figure 9 .
Figure 9. Weekly monitoring using the IoT Platform.

Figure 11 .
Figure 11.Training and validation loss versus accuracy of RNN over counterfactual recommendation.

Figure 12 .
Figure 12.Multiple confusion matrix for monitoring soil accuracy.

Table 1 .
21terature review for soil health based on different proposed models.PH Sensor monitors NPK, EC, and pH.Soil electrical conductivity (EC) may indicate salt concentration.Higher EC values imply plant-harming soil salt.Growing plants need nitrogen, phosphorus, and potassium.It means 20% nitrogen, phosphorus, and potassium in the soil.Soil pH indicates acidity or alkalinity.Acidic soils have pH < 7, while alkaline soils have pH > 7. Electrical conductivity sensors detect soil solution.NPK sensors evaluate soil solution light absorption at different wavelengths.This data can track soil health trends and identify areas that need specialist soil management.LDR soil color sensors like the MNS2-9-W2-CM-020 improve coffee plantation soil health monitoring21.The Maxim Integrated DS3231 time stamp may improve coffee plantation soil health monitoring in numerous ways.Plantation operators can use time stamps to find patterns and trends in soil health data as indicated in Fig.2.
Figure 1.Working prototype for testing soil fertility.NPK

Table 2
2stimates dry land-rich soil in coffee plantations2.IoT sensors may be connected to Arduino using IST.The simple and efficient IST protocol is ideal for connecting many sensors to an Arduino microcontroller.It includes Master Out Slave, in Master in Slave Out, Slave Select, and Serial Clock.SCLK synchronizes master-slave data transfer.MOSI and MISO signals send data from master to slave and slave to master.The owner chooses the slave via SS.A start condition from the master device starts IST communication with the slave.Most starts are high-to-low SS signal changes.After supplying the start condition, the master device can send a MOSI bit per SCLK clock pulse to the slave device.The slave device receives MISO data and delivers a bit to the master device for each SCLK clock pulse.Stop signals from master devices to slave devices halt IST communication.SS signals typically rise during a standstill.Arduino microcontroller board with enough computing power for data handling and communication interfaces.Use appropriate cables to connect each sensor to the microcontroller board for proper pinout and voltage.In Algorithm 1, each sensor's communication protocols are configured for data acquisition.

Table 2 .
Parameters to fertile the coffee plantation soil from dry land.
Coffee plants are sensitive to high levels of salinity.Higher EC levels can stress the plants and reduce their yields Nutrient value Varies depending on the nutrient Varies depending on the nutrient Nutrient deficiencies can reduce the yields and quality of the coffee beans Timestamp Track changes in soil conditions over time Not applicable By tracking the timestamp of the data collected, farmers can identify trends and patterns in the soil parameters Hardware setup has a Microcontroller-Arduino Uno heart of any IoT device, and it is responsible for collecting data from sensors, processing that data, and sending it to the cloud.Sensors-Soil moisture sensor, soil temperature sensor, pH sensor, and nutrient sensor.Wireless Communication Modules-Wi-Fi communication module, Bluetooth communication module, cellular communication module, Irrigation system actuator, fertilizer applicator actuator.AC power supply, DC power supply, battery, SD card, USB flash drive.Software setup has Windows operating system, python 3.6 Amazon Web Services (AWS)0.5,Data Visualization Tools-Matplotlib, simulates the suggested model on PC i5-8600 k, GeForce 1050Ti 4 GB, 16 GB RAM, 250 GB SSD, and 1 TB HDD.The suggested model is evaluated using False Negative, True Positive, True Negative, and False Positive metrics using the Recurrent Neural Network and Counter-Factual Recommendation Generation.

Table 4 .
Measurement Range to fertile the coffee plantation soil from dry land.

Table 5 .
Parameters to fertile the coffee plantation soil from dry land.